<?php

namespace app\api\controller;

use app\admin\model\user\Browses;
use app\common\controller\Api;
use app\common\controller\Frontend;

#[Apidoc\Title("我的浏览记录 版本3.0")]
class Mybrows extends Frontend
{
    protected array $noNeedPermission=["*"];
    #[
        Apidoc\Title("我的浏览记录 版本3.0"),
        Apidoc\Method("POST"),
        Apidoc\Url("/api/Mybrows/index"),
        Apidoc\Query(name: "page", type: "number", require: false, desc: "页码", mock: "1"),
        Apidoc\Param(name: "type", type: "string", require: "true", desc: "对应的类型  houses 转让出租', 'findstore =找房公告'", mock: "houses"),
        Apidoc\Returned("id", type: "int", desc: "Id"),
    ]
    public function index()
    {
        $type=$this->request->param("type",'houses');
        $map = [
            ['user_id', '=', $this->auth->id],
        ];
        if(!empty($type)){
            $map[] = ['type', '=', $type];
        }
        if($type=='houses'){
            $query= (new Browses())->with('houses');
        }else{
            $query= (new Browses())->with('findstore');
        }
        $list =$query
            ->where($map)
            ->paginate();
        $this->success('我的浏览记录', $list);
    }

}